import "lib-flexible/flexible";
import { Button, Cell, IndexAnchor, IndexBar, Popup } from "vant";
// import Vant from 'vant';
import "vant/lib/index.css";
import Vue from "vue";
import VueJson from "vue-jsonp";
import App from "./App.vue";
import { POInstall } from "./options/pageOption";
import router from "./options/router";
import "./plugins/axios";
// import '../public/icon/iconfont.css';
import "./plugins/components";
import store from "./store";
import tool from "./utils/tool";

Vue.use(Button)
  .use(Popup)
  .use(Cell)
  .use(IndexBar)
  .use(IndexAnchor);


router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
// Vue.use(Vant);
//字段对照
// import switchFormatter from './options/formatter'

// Vue.prototype.$formatter = switchFormatter;

//Vue.mixin(pageOption);

router.beforeEach((to, from, next) => {
  //页面加载动画
  // WB.$watch("router", () => {
  //   next();
  // });
  let url = window.location.href;
  if (url.includes("?from=")) {
    // 判断是否携带了 from 参数，这一步灵活变通，只要能判断出是从微信分享链接进来的就 OK
    url = url.replace(/com.+.#/,
      "com/#"
    ); // 利用正则表达式去掉微信携带的 ?from=singlemessage&isappinstalled=0 这串参数，如果这串参数对于你当前的页面有用处的话，可以重新拼接到你正常的链接后面去
    window.location.href = url; // 重定向到正常链接
  }
  next();
});

//装载工具
Vue.prototype.$tool = tool;
//Vue.prototype.$wb = WB;

Vue.use(VueJson);
//装载页面配置
Vue.use(POInstall);
Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

//window.WB = WB;